package org.fatmansoft.teach.controllers;

import org.fatmansoft.teach.payload.request.DataRequest;
import org.fatmansoft.teach.payload.response.DataResponse;
import org.fatmansoft.teach.service.SocialActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/api/social-activity")

public class SocialActivityController {

    @Autowired
    SocialActivityService socialActivityService;
    //初始化显示所有活动
    @PostMapping("/findAllSocialActivities")
    public DataResponse findAllSocialActivities(DataRequest req) {
        return socialActivityService.findAllSocialActivities(req);
    }
    //增加社会活动
    @PostMapping("/saveSocialActivity")
    public DataResponse saveSocialActivity(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.saveSocialActivity(dataRequest);
    }

    //删除社会活动
    @PostMapping("/deleteSocialActivity")
    public DataResponse deleteSocialActivity(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.deleteSocialActivity(dataRequest);
    }

    //更新社会活动
    @PostMapping("/update")
    public DataResponse updateStudentHonor(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.updateSocialActivity(dataRequest);
    }

    //通过名称类型查找社会活动列表
    @PostMapping("/findSocialActivityByNameType")
    public DataResponse findSocialActivityByNameType(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.findSocialActivityByNameType(dataRequest);
    }
    //通过时间查找社会活动列表
    @PostMapping("/findSocialActivityByTime")
    public DataResponse findSocialActivityByTime(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.findSocialActivityByTime(dataRequest);
    }
    //查找特定社会活动
    @PostMapping("/findSocialActivityByNameTime")
    public DataResponse findSocialActivityByNameTime(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.findSocialActivityByNameTime(dataRequest);
    }


    //社会活动插入学生(中间表)
    @PostMapping("/insertStudentSocialActivity")
    public DataResponse insertStudentSocialActivity(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.insertStudentSocialActivity(dataRequest);
    }


    //删除社会活动(中间表)
    @PostMapping("/deleteStudentSocialActivity")
    public DataResponse deleteStudentSocialActivity(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.deleteStudentSocialActivity(dataRequest);
    }

    //通过学生查找社会活动
    @PostMapping("/getStudent")
    public DataResponse getStudentSocialActivity(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.getSocialActivityByStudent(dataRequest);
    }
    //查找社会活动的对应学生
    @PostMapping("/getStudentSocialActivityListByActivityNameTime")
    public DataResponse getStudentSocialActivityListByActivityNameTime(@Valid @RequestBody DataRequest req){
        return socialActivityService.getStudentSocialActivityListByActivityNameTime(req);
    }

     @PostMapping("/getStudentSocialActivityList")
    public DataResponse getStudentSocialActivityList(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.getStudentSocialActivityList(dataRequest);
    }
      @PostMapping("/getSocialActivityByStudent")
        public DataResponse getSocialActivityByStudent(@Valid @RequestBody DataRequest dataRequest) {
        return socialActivityService.getSocialActivityByStudent(dataRequest);
}
   //学生查找自己的社会活动
    @PostMapping("/getStudentSocialActivityByStudentAndSocialActivity")
    public DataResponse getStudentSocialActivityByStudentAndSocialActivity(@Valid @RequestBody DataRequest req){
        return socialActivityService.getStudentSocialActivityByStudentAndSocialActivity(req);
    }
}
